export default [
  {
    path: '/',
    name: 'index',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'home',
    meta: { isShow: true,title:"首页" },
    component: ()=>import('@/pages/Home'),
  },
  {
    path: '/login',
    name: 'login',
    meta: {title:"登录" },
    component: ()=>import('@/pages/Login'),
  },
  {
    path: '/register',
    name: 'register',
    meta: {title:"注册" },
    component: ()=>import('@/pages/Register'),
  },
  {
    path: '/search/:keyword?',
    name: 'search',
    meta: { isShow: true,title:"商品列表" },
    component: ()=>import('@/pages/Search'),
  },
  {
    path: '/detail/:skuId',
    name: 'detail',
    meta: { isShow: true,title:"商品详情" },
    component: ()=>import('@/pages/Detail'),
  },
  {
    path: '/addsuccess',
    name: 'addSuccess',
    meta: { isShow: true, isAuth: true,title:"添加成功" },
    component: ()=>import('@/pages/AddCartSuccess'),
  },
  {
    path: '/shopcart',
    name: 'ShopCart',
    meta: { isShow: true, isAuth: true,title:"购物车" },
    component: ()=>import('@/pages/ShopCart'),
  },
  {
    path: '/trade',
    name: 'Trade',
    meta: { isShow: true, isAuth: true,title:"结算" },
    component: ()=>import('@/pages/Trade'),
    beforeEnter: (to, from, next) => {
      // 在进入路由之前的逻辑
      // 可以通过调用 next() 进行下一步操作
      // next(false) 从哪来回哪去
      if (from.path == '/shopcart' || from.path == '/') {
        next();
      } else {
        next(false);
      }
    },
  },
  {
    path: '/pay',
    name: 'Pay',
    meta: { isShow: true, isAuth: true,title:"支付" },
    component: ()=>import('@/pages/Pay'),
    beforeEnter: (to, from, next) => {
      // 在进入路由之前的逻辑
      // 可以通过调用 next() 进行下一步操作
      // next(false) 从哪来回哪去
      if (from.path == '/trade' || from.path == '/') {
        next();
      } else {
        next(false);
      }
    },
  },
  {
    path: '/paysuccess',
    name: 'PaySuccess',
    meta: { isShow: true, isAuth: true,title:"支付成功" },
    component: ()=>import('@/pages/PaySuccess'),
    beforeEnter: (to, from, next) => {
      // 在进入路由之前的逻辑
      // 可以通过调用 next() 进行下一步操作
      // next(false) 从哪来回哪去
      if (from.path == '/pay' || from.path == '/') {
        next();
      } else {
        next(false);
      }
    },
  },
  {
    path: '/center',
    name: 'Center',
    meta: { isShow: true, isAuth: true,title:"个人中心" },
    component: ()=>import('@/pages/Center'),
  }

]